package com.health.yb.core.utils;

import com.baomidou.mybatisplus.core.toolkit.ArrayUtils;
import com.baomidou.mybatisplus.core.toolkit.LambdaUtils;
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
import com.baomidou.mybatisplus.core.toolkit.support.SerializedLambda;
import org.apache.ibatis.reflection.property.PropertyNamer;

import java.util.HashMap;
import java.util.Map;

/**
 * @author rjwang
 * @version 1.0
 * @date 2019/12/25 15:15
 */
public class CustomLambdaObjectWrapper<T> {

    private Map<String, String> map = new HashMap<>();

    public CustomLambdaObjectWrapper() {
    }

    public CustomLambdaObjectWrapper ignore(SFunction<T, ?>... columns) {
        if (ArrayUtils.isNotEmpty(columns)) {
            for (SFunction<T, ?> column : columns) {
                SerializedLambda lambda = LambdaUtils.resolve(column);
                String fieldName = PropertyNamer.methodToProperty(lambda.getImplMethodName());
                map.put(fieldName, fieldName);
            }
        }
        return this;
    }

    public Map<String, String> getMap() {
        return map;
    }


}
